package zengqiang.接口回调;

import java.awt.*;
import java.awt.event.*;

public class MyFrame extends Frame1 implements ActionListener{

    private final Button btn;

    public MyFrame() {
        this.setSize(600, 400);
        this.setTitle("第一个GUI窗体");
        btn = new Button("点一下");
        btn.addActionListener(this);
        FlowLayout flowLayout = new FlowLayout();
        this.setLayout(flowLayout);
        //添加关闭事件
        this.addWindowListener(new WindowAdapter() {
            @Override
            public void windowClosing(WindowEvent e) {
                super.windowClosing(e);

            }
        });
        this.add(btn);
        this.setVisible(true);
    }

    public static void main(String[] args) {
        new MyFrame();
    }

    //单击事件处理的方法
    @Override
    public void actionPerformed(ActionEvent e) {

        System.out.println("惊喜");
    }
}
